#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    //TableWidget  控件
    //设置列数
    ui->tableWidget->setColumnCount(3);

    //设置水平表头
    ui->tableWidget->setHorizontalHeaderLabels(QStringList()<<"姓名"<<"外号"<<"年龄");

    //设置行数
    ui->tableWidget->setRowCount(5);

    //设置正文
    //ui->tableWidget->setItem(0,0,new QTableWidgetItem("弗拉基米尔 "));

    QStringList nameList;
    nameList<<"发条魔灵"<<"风暴之怒"<<"荒漠屠夫"<<"扭曲树精"<<"战争之王";

    QList<QString> nameList1;
    nameList1<<"奥莉安娜"<<"迦娜"<<"雷克顿"<<"茂凯"<<"潘森";
    for(int i = 0;i<5;i++){
        int col=0;
        ui->tableWidget->setItem(i,col++,new QTableWidgetItem(nameList[i]));
        ui->tableWidget->setItem(i,col++,new QTableWidgetItem(nameList1.at(i)));
        //int 转 string
        ui->tableWidget->setItem(i,col++,new QTableWidgetItem(QString::number(i+8999)));
    }

}

Widget::~Widget()
{
    delete ui;
}
